import request from '@/config/axios'
import {
  SystemUser,
  SystemUserQuery,
  SystemUserStatusUpdate,
  UnlockScreen,
  UpdatePassword
} from '@/api/system/user/types'

export const getSystemUserListApi = (params: SystemUserQuery) => {
  return request.get({ url: '/system/user/list', params })
}

export const getSystemUserDetailsApi = (userId: number) => {
  return request.get({ url: '/system/user/' + userId })
}

export const getDeleteSystemUserApi = (userIds: string) => {
  return request.post({ url: '/system/user/delete', params: { userIds: userIds } })
}

export const getUpdateUserStatusApi = (data: SystemUserStatusUpdate) => {
  return request.post({ url: '/system/user/update/status', data })
}

export const checkUserNameApi = (params) => {
  return request.get({ url: '/system/user/name/check', params })
}

export const checkMobileApi = (params) => {
  return request.get({ url: '/system/user/mobile/check', params })
}

export const checkEmailApi = (params) => {
  return request.get({ url: '/system/user/email/check', params })
}

export const createSystemUserApi = (data: SystemUser): Promise<IResponse<SystemUser>> => {
  return request.post({ url: '/system/user/add', data })
}

export const updateSystemUserApi = (data: SystemUser): Promise<IResponse<SystemUser>> => {
  return request.post({ url: '/system/user/update', data })
}

export const updateUserPwdApi = (data: UpdatePassword) => {
  return request.post({ url: '/system/user/update/pwd', data })
}

export const unlockScreenApi = (params: UnlockScreen) => {
  return request.get({ url: '/system/user/unlock/screen', params })
}

export const lockScreenApi = () => {
  return request.get({ url: '/system/user/lock/screen' })
}

export const isLockScreenApi = () => {
  return request.get({ url: '/system/user/is/lock/screen' })
}
